import React from 'react'
import { changeNav } from '../actions'
import { connect } from 'react-redux'
import { Card, WhiteSpace,Icon,Grid } from 'antd-mobile'
import BizopenApply from '../components/BizopenApply.js'
import BizForm from '../components/BizForm.js'
import { List } from 'antd-mobile';
import { slyAjaxPost } from '../common/ajaxservice.js';
import hhistory from '../history';

const Item = List.Item;
const Brief = Item.Brief;

class MainPage extends React.Component {

	constructor(props){
		super(props);
    this.state = {
      infolist:<Brief>加载中<br />请稍后</Brief>
    };
	}

	componentDidMount(){
		// 需要修改
		let self = this;
		this.props.changeNav({title:"首页"});
		slyAjaxPost("message/notify/list",{
      notifyType:1,
      notifyStatus:2,
      limit: 2,
      page: 1
    }).then(function(res){
			console.log(res);
			
			self.setState({
				infolist:<Brief>{res.data.lists[0].notifyContent}
				<br />{res.data.lists[1].notifyContent}</Brief>
			});
		});
	}
	render(){
		return (
			<div>
				<WhiteSpace size="lg" />
				<BizopenApply></BizopenApply>
				<WhiteSpace></WhiteSpace>
				<WhiteSpace size="lg" />
				<BizForm></BizForm>
				<List renderHeader={() => ''} className="my-list">
					<Item
						arrow="horizontal"
						multipleLine
						onClick={() => { hhistory.push('/message') }}
						platform="android"
					>
						消息
						{ this.state.infolist }
					</Item>
				</List>
			</div>
		);
	}



}

const mapStateToProps = (state) => ({
 
})

const mapDispatchToProps = (dispatch) => {
  return{
    changeNav:navobj => dispatch( changeNav( navobj ) )
  }
}

export default connect( mapStateToProps,mapDispatchToProps )(MainPage);